package com.example.cardstackproject

import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.viewpager.widget.ViewPager
import com.example.cardstackproject.card.SimpleOverlayAdapter

class MainActivity : AppCompatActivity() {

    private lateinit var vp:ViewPager

    private val imgUrls = arrayOf(
        "https://i2.hdslb.com/bfs/archive/961b6650675f97b297bb5ec764ce89b314134544.jpg"
        , "https://i1.hdslb.com/bfs/archive/8db3fd38ae6eb0625e0c3b1d274160294d7bd5f5.jpg"
        , "https://wx4.sinaimg.cn/mw690/8a9320f3ly1hsqsepmjfbj23y8280u0y.jpg"
        ,  "https://i2.hdslb.com/bfs/archive/961b6650675f97b297bb5ec764ce89b314134544.jpg"
        , "https://i1.hdslb.com/bfs/archive/8db3fd38ae6eb0625e0c3b1d274160294d7bd5f5.jpg"
        , "https://wx4.sinaimg.cn/mw690/8a9320f3ly1hsqsepmjfbj23y8280u0y.jpg"
    )

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        this.enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v: View, insets: WindowInsetsCompat ->
            val systemBars = insets.getInsets(
                WindowInsetsCompat.Type.systemBars()
            )
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        vp=findViewById(R.id.example_vp)
        val adapter = SimpleOverlayAdapter(this)
        adapter.setImgUrlsAndBindViewPager(vp, imgUrls, 6)
        vp.adapter = adapter
    }
}